package cn.iocoder.yudao.module.indicator.dao.index;

import cn.iocoder.yudao.module.indicator.domain.dto.IndicatorDto;
import cn.iocoder.yudao.module.indicator.domain.entity.ElementData;
import cn.iocoder.yudao.module.indicator.domain.entity.Indicator;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Arrays;
import java.util.List;

/**
 * @author ZYW
 * @description: TODO
 * @date 2023-12-26 15:54
 */

@Repository
@Mapper
public interface IndicatorDao extends BaseMapperX<Indicator> {

    default PageResult<Indicator> selectPage(IndicatorDto indicatorDto) {
        return selectPage(indicatorDto, new LambdaQueryWrapperX<Indicator>()
                .likeIfPresent(Indicator::getIndexName, indicatorDto.getIndexName())
                .eqIfPresent(Indicator::getIndexName,indicatorDto.getRealIndexName())
                .orderByDesc(Arrays.asList(Indicator::getCreateTime)));
    }

    @Select("select * from element_data where id in (${ids})")
    List<ElementData> getElementDataByIds(String ids);

}
